#include "stdafx.h"

#include <Magick++.h> 
#include <boost/filesystem/fstream.hpp>
#include <boost/filesystem.hpp>
#include <boost/xpressive/regex_actions.hpp>
#include <boost/xpressive/xpressive.hpp>

#include "fileIter.h"
#include "tiff2pdf.h"

using namespace std; 
using namespace Magick;   

/*
string ReadAll(const char* fileName){
	string inFileBuf;
	ifstream ifs(fileName);

	if (!ifs){
		return inFileBuf;
	}

	ifs.unsetf(ios::skipws);//unset skip space

	copy(istream_iterator<char>(ifs), istream_iterator<char>(), back_inserter(inFileBuf));

	return inFileBuf;
}

vector<string> ReadLines1(const char* fileName)
{

   vector<string> lines;

   ifstream ifs(fileName);

   if (!ifs){
		return lines;
	}

   string line;      
		
   while ( getline(ifs, line, '\n') ) 
	{         
		lines.push_back(string(line));
	}
	return lines;	

}
*/
//using namespace boost::filesystem;

using namespace boost::xpressive;
namespace fs = boost::filesystem;

    
	//operation input and transaction management:
	
/*
bool find_file( const path & dir_path,         // in this directory,
                const std::string & file_name, // search for this name,
                path & path_found )            // placing path here if found
{
  
  mark_tag tiff(1);
	
  cregex tiffFileName = (tiff= +(_w | _d))
		   >> '.' >> 'tiff';

  cmatch what;

  if ( !exists( dir_path ) ) return false;
  directory_iterator end_itr; // default construction yields past-the-end
  for ( directory_iterator itr( dir_path );
        itr != end_itr;
        ++itr )
  {
    if ( is_directory(itr->status()) )
    {
      if ( find_file( itr->path(), file_name, path_found ) ) return true;
    }
    else// see below
    {
	  string thisFile = itr->leaf();

      if(regex_search(thisFile.c_str(), what, tiffFileName))
		    {
		        std::cout << what[0] << '\n'; // whole match
				//FileCurrMode[fileIndex] = atoi(what[mode].str().c_str());
			
		    }
      path_found = itr->path();
    }
  }
  return false;
}
*/

int main(int argc, char** argv)
{
	int i;
    
	//using namespace boost::filesystem;

	std::string rootDir;

	rootDir = argv[1];

	InitializeMagick("C:\Program Files\ImageMagick-6.6.1-Q16");

	fs::path rootPath(rootDir); 
	fs::path foundPath;

	fileIter tiffIter;
	tiffIter.IterTiff(rootPath, foundPath);

	return 0;
}
